class Solution {
public:
    int temperatureTrend(vector<int>& temperatureA, vector<int>& temperatureB) {
        int ans = 0;
        vector<int>st;
        int n = temperatureA.size();
        for (int i = 1; i < n; i++) {
            int x = temperatureA[i - 1] - temperatureA[i];
            int z = 0;
            if (x > 0)z = 1;
            else if (x < 0) z = -1;
            st.push_back(z);
        }
        int k = 0;
        for (int i = 1; i < n; i++) {
            int x = temperatureB[i - 1] - temperatureB[i];
            int z = 0;
            if (x > 0)z = 1;
            else if (x < 0) z = -1;
            if (st[i - 1] == z) {
                k++;
                ans = max(k, ans);
            }
            else k = 0;
        }
        return ans;
    }
};